/*************************************************************************
 *
 *   file		: Mounted.cs
 *   copyright		: (C) The WCell Team
 *   email		: info@wcell.org
 *   last changed	: $LastChangedDate: 2009-03-07 06:58:12 +0000 (Sat, 07 Mar 2009) $
 *   last author	: $LastChangedBy: ralekdev $
 *   revision		: $Rev: 784 $
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 *************************************************************************/

using NLog;
using WCell.Constants.NPCs;

namespace WCell.RealmServer.Spells.Auras.Handlers
{
	/// <summary>
	/// Applies a mount-aura
	/// </summary>
	public class MountedHandler : AuraEffectHandler
	{
		private static Logger log = LogManager.GetCurrentClassLogger();

		protected internal override void Apply()
		{
			uint creatureId = (uint)SpellEffect.MiscValue;
			// uint displayId = LookupMountId(creatureId);

			var id = (MountId)m_spellEffect.MiscValue;
			m_aura.Auras.Owner.Mount(id);

			m_aura.Auras.MountAura = m_aura;

			// some flying mounts dont have a flying effect, so we need to apply it here:
			if (m_aura.Spell.IsFlyingMount && !m_aura.Spell.HasFlyEffect)
			{
				m_aura.Auras.Owner.Flying++;
			}
		}

		protected internal override void Remove(bool cancelled)
		{
			// some flying mounts dont have a flying effect, so we need to remove it here:
			if (m_aura.Spell.IsFlyingMount && !m_aura.Spell.HasFlyEffect)
			{
				m_aura.Auras.Owner.Flying--;
			}
			m_aura.Auras.Owner.DoDismount();
		}
	}
};
